﻿using System;
using System.Collections.Generic;
using System.Text;

namespace SharpSoft.Html
{
    using AngleSharp.Dom;
    public static class AngleSharpExtensions
    {
        public static IHtmlCollection<IElement> q(this IDocument doc, string selector)
        {
            return doc.QuerySelectorAll(selector);
        }
        public static IElement q1(this IDocument doc, string selector)
        {
            return doc.QuerySelector(selector);
        }

        public static string text(this IHtmlCollection<IElement> tags)
        {
            foreach (var item in tags)
            {
                return item.TextContent;
            }
            return "";
        }
        public static string html(this IHtmlCollection<IElement> tags)
        {
            foreach (var item in tags)
            {
                return item.InnerHtml;
            }
            return "";
        }
        public static string attr(this IHtmlCollection<IElement> tags, string attrname)
        {
            foreach (var item in tags)
            {
                return item.GetAttribute(attrname);
            }
            return "";
        }
        public static string text(this IElement tags)
        {
            return tags.TextContent;
        }
        public static string html(this IElement tags)
        {
            return tags.InnerHtml;
        }
        public static string attr(this IElement tags, string attrname)
        {
            return tags.GetAttribute(attrname);
        }
         
    }
}
